package hanjia;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/11-下午8:14
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode112 {



    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root==null) {
            return  false;
        }
        if (root.val==targetSum&&root.left==null&&root.right==null){
            return true;
        }

        return hasPathSum(root.left,targetSum-root.val)||hasPathSum(root.right,targetSum-root.val);


    }
}
